﻿Public Class frmInvolucro
    Inherits formPadrao

    Private gridDrogas As New DataGridView
    Private fracionar As Boolean = Nothing
    Private objdata As New DataTable
    Private validou As Boolean = False
    Private formConstatacao As New frmConstatacaoPreliminar

    Public Property getValidou As Boolean
        Get
            Return validou
        End Get
        Set(value As Boolean)
            validou = value
        End Set
    End Property

    Public Property getGridDrogas() As DataTable
        Get
            Return objdata
        End Get
        Set(value As DataTable)
            objdata = value
        End Set
    End Property


    Public Property getFracionar() As Boolean
        Get
            Return fracionar
        End Get
        Set(value As Boolean)
            fracionar = value
        End Set
    End Property

    Private Sub cmdOk_Click(sender As Object, e As EventArgs) Handles cmdOk.Click

        If validaCampos() Then
            validou = True
            objdata.Rows.Add(cmbInvolucro.Text, txtInvolucroIC.Text, txtInvolucroAut.Text)
            limpaCampos()
            Me.Close()
        End If

    End Sub
    Private Sub limpaCampos()
        cmbInvolucro.SelectedIndex = -1
        txtInvolucroAut.Text = String.Empty
        txtInvolucroIC.Text = String.Empty
    End Sub
    Private Sub frmInvolucro_Load(sender As Object, e As EventArgs) Handles Me.Load

        '----------------------------------------------------------------------
        ' CRIANDO MEU DATATABLE
        '----------------------------------------------------------------------
        objdata.Columns.Add("involucro", Type.GetType("System.String"))
        objdata.Columns.Add("numInvolucroIC", Type.GetType("System.String"))
        objdata.Columns.Add("numInvolucroAut", Type.GetType("System.String"))

    End Sub

    

    Private Sub cmbInvolucro_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cmbInvolucro.SelectedIndexChanged

        If cmbInvolucro.Text.Equals("invólucro de segurança") Then

            If fracionar Then
                lbAut.Visible = True
                lbIc.Visible = True
                txtInvolucroAut.Visible = True
                txtInvolucroIC.Visible = True
            Else
                lbAut.Visible = False
                lbIc.Visible = True
                txtInvolucroAut.Visible = False
                txtInvolucroIC.Visible = True
            End If
        Else
            lbAut.Visible = False
            lbIc.Visible = False
            txtInvolucroAut.Visible = False
            txtInvolucroIC.Visible = False

        End If
    End Sub

    Private Sub txtInvolucroIC_Leave(sender As Object, e As EventArgs) Handles txtInvolucroIC.Leave
        If Not txtInvolucroIC.Text.Equals(String.Empty) Then
            erro.SetError(txtInvolucroIC, String.Empty)
        End If
    End Sub

    Private Sub txtInvolucroAut_Leave(sender As Object, e As EventArgs) Handles txtInvolucroAut.Leave
        If Not txtInvolucroAut.Text.Equals(String.Empty) Then
            erro.SetError(txtInvolucroAut, String.Empty)
        End If
    End Sub
End Class